from variable import *

# def copy_590():
#     # 5. copy590工单，然后更改
#     if not os.path.isfile("a.txt"):
#         fd = open("a.txt", mode="a", encoding="utf-8")
#         for i in range(10):
#             fd.write("This is line %d\r\n" % (i + 1))
#         fd.close()
#     if not os.path.isfile(File_590_Name):
#         os.rename("a.txt", File_590_Name)

def copy_590():
    os.chdir(MailWork_path)
    key = "590"
    if os.path.exists(Report_BasicPath):
        print(Report_BasicPath + " exitst")
        for root, dirs, files in os.walk(Report_BasicPath):
            if root == Report_BasicPath:  # 限定在Report_BasicPath下遍历文件
                for file in files:
                    if key in file:
                        print('找到包含"' + key + '"字符的文件,绝对路径为----->' + Report_BasicPath + '/' + file)
                        print('复制到----->' + MailWork_path + "/" + file)
                        src_file = os.path.join(root, file)
                        shutil.copy(src_file, MailWork_path)

    if not os.path.isfile(File_590_Name):
        os.rename(src_file, File_590_Name)

    if os.path.exists(MailWork_path + "/" + "590.xlsm"):
        os.remove(MailWork_path + "/" + "590.xlsm")
        print('移除后术前目录下有文件：%s' % os.listdir(MailWork_path))
    pass
